package com.hejing.object类.Object类之equals方法;

/**
 * ClassName: UserTest
 * Package: com.hejing.object类.Object类之equals方法
 * Description:
 *
 * @Author: HeJing
 * @Create: 2023-03-26 21:21
 * @Version: 1.0
 */
public class UserTest {
    public static void main(String[] args) {
        User u1 = new User("Tom", 12);
        User u2 = new User("Tom", 12);

        System.out.println(u1.equals(u2)); // 重写equals()方法之前: false,  重写equals()方法之后: true

        String str1 = new String("hello");
        String str2 = new String("hello");
        System.out.println(str1 == str2);      // false
        System.out.println(str1.equals(str2)); // true
    }
}























